<!--角色列表的编辑功能-->
<template>
  <div>
    <el-dialog title="修改角色信息" v-model="updateDialogVisible" width="30%">
      <el-form  label-position="left"  :model="updateForm"  label-width="20%">
        <el-form-item label="角色名称">
          <el-input v-model="updateForm.roleName" clearable></el-input>
        </el-form-item>
        <el-form-item label="角色描述" >
          <el-input v-model="updateForm.roleDesc" clearable></el-input>
        </el-form-item>
      </el-form>
      <template #footer>
    <span class="dialog-footer">
      <el-button @click="updateDialogVisible = false">取 消</el-button>
      <el-button type="primary" @click="updated">确 定</el-button>
    </span>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import {request} from "../../../network/axios";
import {ElMessage} from "element-plus";

export default {
  name: "UpdateDialog",
  data(){
    return{
      updateForm:{
        id:'',
        roleName:'',
        roleDesc:''
      },
      updateDialogVisible:false
    }
  },
  methods:{
    updated() {
      request({
        url:`roles/${this.id}`,
        method:'put',
        data:this.updateForm
      }).then(res=>{
        if(res.status!==200)  return ElMessage.error("获取失败")
        ElMessage.success("修改成功")
        //关闭对话框
        this.updateDialogVisible = false
        //重新刷新页面
       this.$parent.getRolesList()
      })
  },
  }
}
</script>

<style scoped>

</style>